<{include file="top_v2.html" }>
</head>
<body>
    <div id="wrap" class="pt detail-page houseOrder">
        <div class="header themeRed">
            订单
            <a href="javascript:window.history.back();" class="back"></a>
        </div>
        <div class="ordList">
            <ul id="datalist">
                <{include file="HouseWork/orderListItem.html" }>
            </ul>
        </div>
        <div class="pjPop">
            <div class="con">
                <div class="tit">
                    服务评价
                    <a href="javascript:;" class="btn_close"></a>
                </div>
                <textarea name="pjCon" id="pjCon"></textarea>

                <div id="score">
                    <label>服务评分</label>
                    <ul class="sp">
                        <li></li>
                        <li></li>
                        <li></li>
                        <li></li>
                        <li></li>
                    </ul>
                    <input type="hidden" name="score" id="v" value='0'  />
                </div>

                <a href="javascript:;" class="btnM js_send">确定</a>
            </div>
        </div>
    </div>
    <script>
        $(function() {
            //关闭评价弹窗
            $(document).on('click', '.btn_close', function () {
                $('.pjPop').hide();
            });
            //发表评价
            $(document).on('click', '.js_send', function () {
                var _con=$('#pjCon').val();
                    if(_con==''){
                        tip('请填写评价类容');
                        return false;
                    }
                    var score=$('#v').val()
                    $.post("<{u('comment')}>",{orderId:orderID,score:score,con:encodeURIComponent(_con)},function(ret){
                        tip(ret.msg);
                        if (ret.status==0) {
                            setTimeout(function () {
                                window.location.reload();
                            }, 1000);
                        }
                    },'json');
            });
        });
        var orderID=0;
        function comment(obj){
            //获取订单ID
            orderID=$(obj).attr('data-orderID');
            $('.pjPop').show();
        }

        $('#score li').on('click',function(e){
            var t=e.target;
            var val=$(t).index()+1;
            $(t).prevAll().andSelf().addClass('on');
            $(t).nextAll().removeClass('on');
            $('#v').val(val)
        });
    </script>


    <script type="text/javascript">
        var loadMore = "<{U('HouseWork/orderListMore')}>";
        var page=1;
        //拖动加载
        var flagData = true;
        var flagAjax = true;
        //加载
        function load_more(postData){
            if(! flagAjax){
                return false;
            }
            flagAjax = false;
            loadObj = load();
            $.getJSON(loadMore,postData , function(data){
                layer.close(loadObj);
                if (data.status != 0) {
                    tip("数据获取失败，请稍后重试或联系管理员解决！");
                } else {
                    ++page;
                    $(".active-list").append(data.dataHTML);
                    if (data.isPage) flagAjax = true;
                }

            },'json');
        }

        var tmp_scroll = 0;
        //拖动加载
        function scroll_load(postData){
            if (tmp_scroll == $(window).height() + $(window).scrollTop()) {
                return;
            }
            tmp_scroll = $(window).height() + $(window).scrollTop();
            var jia_scroll = $(document).height() - ($(window).height() + $(window).scrollTop());
            if (jia_scroll < 100 && flagData) {
                load_more(postData);
            }
        }

        $(window).scroll(function(){
            if(page==1) page=2;
            scroll_load({page:page});
        });

    </script>

</body>

</html>